package com.zero_x.service.impl;

import com.zero_x.dao.SysUserMapper;
import com.zero_x.entity.Supplier;
import com.zero_x.entity.SysUser;
import com.zero_x.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Transactional
@Service("sysUserService")
public class SysUserServiceImpl implements SysUserService {
    @Autowired
    private SysUserMapper sysUserMapper;
    @Override
    public List<SysUser> getList(SysUser sysUser) {
        try{
            return sysUserMapper.selectSysUserList(sysUser);
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
    }

    @Override
    public int add(SysUser sysUser) {
        int row = 0;
        try{
            if (sysUserMapper.add(sysUser) > row) {
                System.out.println("添加成功");
            }
        } catch (RuntimeException e) {
            e.printStackTrace();
            throw e;
        }
        return row;
    }

    @Override
    public List<Supplier> selectSupplier(Supplier supplier) {
        return sysUserMapper.selectSupplier(supplier);
    }

    @Override
    public int SupplierAdd(Supplier supplier) {
        return sysUserMapper.SupplierAdd(supplier);
    }

    @Override
    public int SupplierDelete(Integer id) {
        return sysUserMapper.SupplierDelete(id);
    }

    @Override
    public int SupplierUpdate(Supplier supplier) {
        return sysUserMapper.SupplierUpdate(supplier);
    }

    public SysUserMapper getSysUserMapper() {
        return sysUserMapper;
    }

    public void setSysUserMapper(SysUserMapper sysUserMapper) {
        this.sysUserMapper = sysUserMapper;
    }
}
